package cn.wsalix.admin.service.impl;

import java.util.Date;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.wsalix.sys.service.DailyRecordService;

/**
 * @author jskyme 管理员切面，新增角色、菜单、权限时，自动给管理员赋权限
 */
@Aspect
@Service("adminAspect")
public class AdminMenuAspect {
	protected Logger logger = LoggerFactory.getLogger(getClass());

	@Pointcut("execution(* cn.wsalix.admin.service.impl.MenuServiceImpl.add(..))")
	public void menuAdd() {
	};
	@Pointcut("execution(* cn.wsalix.admin.service.impl.MenuServiceImpl.edit(..))")
	public void menuEdit() {
	};
	@Pointcut("execution(* cn.wsalix.admin.service.impl.MenuServiceImpl.delete(..))")
	public void menuDelete() {
	};

	@Autowired
	private DailyRecordService dailyRecordService;// 记录订单数/订单付款数

	@Before("menuAdd()")
	public void menuAddBefore(JoinPoint call) {
		logger.info("【注解-前置通知】:方法正常结束了");		
	}

	@Transactional
	@Around("menuAdd()")
	public Object doMenuAddProfiling(ProceedingJoinPoint pjp) throws Throwable {
		Object retVal = pjp.proceed();
		return retVal;
	}

	@AfterReturning("menuAdd()")
	public void menuAddAfterReturn(JoinPoint call) {
		logger.info("【注解-后置通知】:方法正常结束了");
	}

	@Transactional
	public void newDay() {
		
		// super.add(saleDaily);
	}

}
